//
//  ViewBuilder+Extensions.swift
//  SwiftUIFly
//
//  Created by shen on 2023/10/18.
//

import SwiftUI

public extension View {
    @ViewBuilder func `if`<T: View, V: View>(
        _ condition: Bool,
        apply transform: (Self) -> T,
        else elseTransform: ((Self) -> V)? = nil
    ) -> some View {
        if condition {
            transform(self)
        } else {
            if let elseTransform {
                elseTransform(self)
            } else {
                self
            }
        }
    }
}
